export class Order {
	orderId: string;
	userId: string;
	createTime: number;
	amount: number; // 金额
	target: 'up' | 'down'; // 标的
	charge: number; // 手续费
	result: number; // 结果，盈亏多少
	status: 'placed' | 'finish'; // 状态

	constructor(data) {
		Object.assign(this, data);
	}
}

export let processOrders = (orders: Array<Order>, buyPrice) => {
	//
	let totalForUp = 0,
		totalForDown = 0;
	orders.forEach(p => {
		console.log(p);
		if (p.target == 'up') totalForUp += p.amount;
		else if (p.target == 'down') totalForDown += p.amount;
	});
	console.log('total up', totalForUp, totalForDown);
	if (totalForUp >= totalForDown) {
		return 1;
	} else {
		return -1;
	}
};
